/* by wildw1ng */

private ["_markerWestBase","_markerEastBase","_markerGuerBase"];

_markerWestBase = createMarker ["respawn_west", getMarkerPos "baseWest"];
_markerWestBase setMarkerTextLocal "Base";
_markerWestBase setMarkerType "b_unknown";
_markerWestBase setMarkerAlpha 0;


_markerEastBase = createMarker ["respawn_east", getMarkerPos "baseEast"];
_markerEastBase setMarkerTextLocal "Base";
_markerEastBase setMarkerType "o_unknown";
_markerEastBase setMarkerAlpha 0;


_markerGuerBase = createMarker ["respawn_guerrila", getMarkerPos "baseGuerrila"];
_markerGuerBase setMarkerTextLocal "Base";
_markerGuerBase setMarkerType "n_unknown";
_markerGuerBase setMarkerAlpha 0;


[] spawn
{
	private ["_markerFlagsWest","_markerFlagsEast","_markerFlagsGuer","_marker","_flagName","_pos"];
	_markerFlagsWest = [];
	_markerFlagsEast = [];
	_markerFlagsGuer = [];
	while {true} do
	{
		sleep 1.0;
		{
			if (_x getVariable "side" == west) then
			{
				if (count _markerFlagsWest <= _forEachIndex) then {
					_markerFlagsWest set [_forEachIndex, format ["respawn_westFlag%1", _forEachIndex]];
				};
				_marker = _markerFlagsWest select _forEachIndex;
				_pos = getMarkerPos (_x getVariable "namemarker");
				if (markerType _marker == "") then {
					createMarkerLocal [_marker, _pos];
				};
				_marker setmarkerposLocal _pos;
				_flagName = _x getVariable "name";
				_marker setMarkerTextLocal _flagName;
				_marker setMarkerTypeLocal "mil_flag";
				_marker setMarkerAlphaLocal 0;
			} else {
				_marker = format ["respawn_westFlag%1", _forEachIndex];
				if (markerType _marker != "") then {
					deleteMarkerLocal _marker;
				};
			};
			if (_x getVariable "side" == east) then
			{
				if (count _markerFlagsEast <= _forEachIndex) then {
					_markerFlagsEast set [_forEachIndex, format ["respawn_eastFlag%1", _forEachIndex]];
				};
				_marker = _markerFlagsEast select _forEachIndex;
				_pos = getMarkerPos (_x getVariable "namemarker");
				if (markerType _marker == "") then {
					createMarkerLocal [_marker, _pos];
				};
				_marker setmarkerposLocal _pos;
				_flagName = _x getVariable "name";
				_marker setMarkerTextLocal _flagName;
				_marker setMarkerTypeLocal "mil_flag";
				_marker setMarkerAlphaLocal 0;
			} else {
				_marker = format ["respawn_eastFlag%1", _forEachIndex];
				if (markerType _marker != "") then {
					deleteMarkerLocal _marker;
				};
			};
			if (_x getVariable "side" == resistance) then
			{
				if (count _markerFlagsGuer <= _forEachIndex) then {
					_markerFlagsGuer set [_forEachIndex, format ["respawn_guerrilaFlag%1", _forEachIndex]];
				};
				_marker = _markerFlagsGuer select _forEachIndex;
				_pos = getMarkerPos (_x getVariable "namemarker");
				if (markerType _marker == "") then {
					createMarkerLocal [_marker, _pos];
				};
				_marker setmarkerposLocal _pos;
				_flagName = _x getVariable "name";
				_marker setMarkerTextLocal _flagName;
				_marker setMarkerTypeLocal "mil_flag";
				_marker setMarkerAlphaLocal 0;
			} else {
				_marker = format ["respawn_guerrilaFlag%1", _forEachIndex];
				if (markerType _marker != "") then {
					deleteMarkerLocal _marker;
				};
			};
		} forEach LIB_mp_flags;
	};
};